﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.IncomeMoney.Search;

namespace University.Workshop.Presentation.IncomeMoney
{
    /// <summary>
    /// Interaction logic for SearchIncome.xaml
    /// </summary>
    public partial class SearchIncome : Page, ISearchIncomeView
    {
        PresenterSearchIncome pSearchIncome;
        public SearchIncome()
        {
            InitializeComponent();
            pSearchIncome = new PresenterSearchIncome(this);
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            App.Current.MainWindow.Title = "Buscar Ingresos";
        }

        public void NavigateToRead(Model.WaterCollectControl waterControl)
        {
            this.NavigationService.Navigate(new CollectControl.WaterCollectControl.WaterCollectControlRead(waterControl));
        }

        public void NavigateToRead(Model.OtherCollectControl otherControl)
        {
            this.NavigationService.Navigate(new CollectControl.OtherCollectControl.OtherCollectControlRead(otherControl));
        }

        public void NavigateToRead(Model.FineCollectControl fineControl)
        {
            this.NavigationService.Navigate(new CollectControl.FineCollectControl.FineCollectControlRead(fineControl));
        }

        #region Fields
        public DateTime? InitialDate
        {
            get
            {
                return initialDateDpk.SelectedDate;
            }
        }

        public DateTime? EndDate
        {
            get
            {
                return endDateDpk.SelectedDate;
            }
        }

        public ICollection<Model.CollectControl> JournalEntriesFinded
        {
            set
            {
                collectControlFindeddDgv.ItemsSource = null;
                collectControlFindeddDgv.ItemsSource = value;
            }
        }

        public decimal TotalMoney
        {
            set
            {
                totalMoneyTxt.Text = value.ToString();
            }
        }
        #endregion

        #region Buttons Actions
        private void SearchBtn_Click(object sender, RoutedEventArgs e)
        {
            pSearchIncome.SearchInIncome();
        }

        private void ShowOtbDataBtn_Click(object sender, RoutedEventArgs e)
        {
            pSearchIncome.SendToRead((Model.CollectControl)collectControlFindeddDgv.SelectedItem);
        }
        #endregion

        #region ErrorMessage
        public void NotifyErrorMessage(string message)
        {
            MessageBox.Show(App.Current.MainWindow, message, "Error!!!", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.RightAlign);
        }
        #endregion





    }
}
